class ImageNode {
  // 图片的坐标信息
  private coorDinate: number = 0
  // 图片信息
  private imageType: string

  // 获取图片信息
  getImageType(): string {
    return this.imageType
  }

  // 初始化
  constructor(coorDinate: number, imageType: string) {
    this.coorDinate = coorDinate
    this.imageType = imageType
  }

  Show(): void {
    console.log(`坐标为${this.coorDinate}的图片是${this.imageType}`)
  }

}

(function () {
  let imageList: Map<number, ImageNode> = new Map<number, ImageNode>()
  let randomNumber = 0

  for (let i = 0; i < 10; i++) {
    randomNumber = Math.floor(Math.random() * 10)
    switch (randomNumber / 2) {
      case 0:
        imageList.set(i, new ImageNode(i, '狮子'))
        break
      case 1:
        imageList.set(i, new ImageNode(i, '老虎'))
        break
      case 2:
        imageList.set(i, new ImageNode(i, '大象'))
        break
      case 3:
        imageList.set(i, new ImageNode(i, '长颈鹿'))
        break
      default:
        imageList.set(i, new ImageNode(i, '狮子'))
        break
    }
  }

  console.log('图像准备完毕！')

  for (let i = 0; i < 10; i++) {
    imageList.get(i)?.Show()
  }

  let A = 0
  let B = 0
  while (A == B) {
    A = Math.floor(Math.random() * 10)
    B = Math.floor(Math.random() * 10)
  }

  // 比较 A & B 图片
  if (imageList.get(A)?.getImageType() === imageList.get(B)?.getImageType()) {
    console.log(`坐标${A}和坐标${B}的图片相同,可以消除`)
  } else {
    console.log(`坐标${A}和坐标${B}的图片不同,无法消除`)
  }
}())